package cn.snow.boot.weather.controller;

import cn.snow.boot.weather.service.WeatherService;
import cn.snow.boot.weather.vo.WeatherResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 对接前台REST服务的Controller类
 *
 * @author liuwanxiang
 * @version 2017/9/10
 */
@RestController
@RequestMapping("/weather")
public class WeatherController {

    @Autowired
    private WeatherService weatherService;

    @RequestMapping("/cityid/{cityId}")
    public WeatherResponse getDataByCityId(@PathVariable("cityId") String cityId){
        return weatherService.getDataByCityId(cityId);
    }

    @RequestMapping("/cityname/{cityName}")
    public WeatherResponse getDataByCityName(@PathVariable("cityName") String cityName){

        System.out.println("-----------------");

        return weatherService.getDataByCityName(cityName);
    }

}
